<?php
namespace App\Http\Controllers;

use App\Models\Government;
use Illuminate\Support\Facades\Schema;

class GovernmentController extends WxBaseController{
    protected $except=['index','show'];
    public function index($type=1,$num=10){
        $govs = Government::where('type',$type)->simplePaginate($num);
        editImageUrl($govs);
        return $this->apiReturn(true,'success',$govs);
    }
    public function show($id){
        $gov = Government::where('id',$id);
        //更新浏览量
        if(Schema::hasColumn('governments', 'watch')){
            $gov->increment('watch');
        };
        $arr = $gov->get();
        editImageUrl($arr);
        return $this->apiReturn(true,'success',$arr);
    }
}